import type {Graph} from "@/business/entity/graph/graph.entity";
import type {PanelService} from "@/business/interface/panel.interface";
import {PanelServiceImpl} from "@/business/service/panel.service";
import type {Panel} from "@/business/entity/panel/panel.entity";

/**
 *  图形绘制策略抽象工厂类
 * @author JiangXincan
 * @date 2023/01/29 13:56
 */
export abstract class DrawAbstractFactory {

    // 当前画布对象
    private readonly _panel: Panel;

    protected constructor(panel: Panel) {
        this._panel = panel;
    }

    /**
     *  绘图前处理，创建画布
     * @date 2023/01/29 14:14
     * @return CanvasRenderingContext2D
     */
    protected createCanvas2DContext(): CanvasRenderingContext2D {
        const panelServiceImpl: PanelService = new PanelServiceImpl();
        return panelServiceImpl.create(this._panel);
    }

    /**
     *  绘图核心处理抽象类
     * @date 2023/01/29 14:14
     * @return void
     */
    public abstract draw(graph: Graph): void;

}